package com.jzo2o.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jzo2o.health.model.domain.ReservationSetting;
import org.apache.ibatis.annotations.Insert;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.PostMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author itcast
 * @since 2023-11-01
 */

public interface ReservationSettingMapper extends BaseMapper<ReservationSetting> {
    @Update("UPDATE reservation_setting SET reservations = reservations + 1 WHERE id = #{id} AND reservations < number")
    Integer updateReservations(@Param("id") Integer id);

   // @Select("SELECT * FROM reservation_setting WHERE YEAR(reservation_date) = #{year} AND MONTH(reservation_date) = #{month}")
    //List<ReservationSetting> getReservationSettingsByMonth(@Param("year") int year, @Param("month") int month);

    //数据库查询日期时间
    @Select("select order_date from reservation_setting where order_date>=#{MonthDay01} and order_date<=#{MonthEndDay} and number>reservations")
    List<String>getReservationDateByMonth(LocalDate MonthDay01, LocalDate MonthEndDay);

    // 添加日志输出
}
